package com.glinsoft.ticktak.controller.view;

import com.glinsoft.ticktak.util.HttpInfo;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.ModelAttribute;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.time.Instant;

@Controller
@Slf4j
public class BaseController {




    /**
     * 填充model通用数据
     * @param request
     * @param model
     */
    @ModelAttribute
    public void fulfillModel(HttpServletRequest request, HttpServletResponse response, Model model){
        String ip = HttpInfo.getClientIp(request);
        log.info("==> Request IP: {}",ip);
        model.addAttribute("instant",Instant.now());
        model.addAttribute("ip",ip);
    }

}
